<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>


</head>
<body>

<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<input type="file" id="abc" name="abc"/>
<button>上传文件</button>

<script>
    // 创建FormData对象
    var formData = new FormData();

    $('button').click(function (){
        formData.append("abc",$('#abc')[0].files[0]);
        $.ajax({
            url: 'http://localhost:8080/upload',
            type: 'post',
            data: formData,
            processData: false,
            contentType: false,  // jquery不要处理请求
            success:function (){
                alert("上传成功");
            }
        })
    });
</script>

</body>
</html>